package es.ats.codington.festival.junit.daos;

import static org.junit.Assert.*;

import java.sql.Connection;
import java.util.ArrayList;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.ats.codington.festival.daos.EventSignUpDAOImp;
import es.ats.codington.festival.daos.VisitorDAOImp;
import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.domain.EventSignUp;
import es.ats.codington.festival.domain.Visitor;
import es.ats.codington.festival.utils.FERSDataConnection;

public class tEventSingUpDAO extends TestCase {

	EventSignUp event;
	EventSignUpDAOImp eventDAO;
	Connection con;
	@Before
	protected void setUp() throws Exception {
		super.setUp();
		event= new EventSignUp(1,1);
		eventDAO = new EventSignUpDAOImp();
		con = FERSDataConnection.getConnection();
	}
		
	
	@After
	protected void tearDown() throws Exception {
		super.tearDown();
		con.close();
	}
	
	@Test
	public void testSignUpToEvent(){
		int nRow = 0;
		nRow = eventDAO.signUpToEvent(event.getUserId(),event.getEventId(),con);
		assertEquals(1,nRow);
	}
	@Test
	public void testUsignUpToEvent(){
		int nRow = 0;
		nRow = eventDAO.unsignUpToEvent(event.getUserId(),event.getEventId(),con);
		assertEquals(1,nRow);
	}

	@Test
	public void testEventForUser(){
		ArrayList<Event> listIdEvents = new ArrayList<Event>();
		listIdEvents = eventDAO.eventForUser(event.getUserId(), con);
		assertEquals(0,listIdEvents.size());
	}
	@Test
	 public void testUnEventForUser(){
		ArrayList<Event> listIdEvents = new ArrayList<Event>();
		listIdEvents = eventDAO.eventForUser(event.getUserId(), con);
		assertEquals(0,listIdEvents.size());
	}
	
}
